#include<vector>
#include<queue>
using namespace std;
class KthLargest {
public:
    priority_queue<int, std::vector<int>, std::greater<int>> que;
    int _k;

    KthLargest(int k, vector<int>& nums) {
        int i = 0;
        _k = k;
        for (auto& e : nums)
            que.push(e);


    }

    int add(int val) {
        que.push(val);
        while (que.size() != _k)
            que.pop();
        return que.top();
    }
};

/**
 * Your KthLargest object will be instantiated and called as such:
 * KthLargest* obj = new KthLargest(k, nums);
 * int param_1 = obj->add(val);
 */